<html>
<head>
	<base target="_blank"></base>
	<link href="/static/css/common.css" rel="stylesheet" type="text/css">
	<link href="/static/css/buttons.css" rel="stylesheet" type="text/css">
</head>
<body>
	
<a href="/shanshenmiao/list">list</a>
<br>
<a href="/shanshenmiao/crawler">crawler</a>
<hr>
<div class="button green large breath">按钮</div>
<hr>
<a href="http://www.shenmu.com/pk/data">data</a>
<hr>
K: <input id="ipt_K" value="0.7"> <br>
<button onclick="doCalc()">计算</button>
<div id="calcResult"></div>
<script type="text/javascript" src="../js/jquery-1.7.1.js"></script>
<script type="text/javascript">
function calc(n, K){
	//(1/K^n - 1)/(1-K)
	var ret = (1/Math.pow(K, n) - 1) / (1 - K);
	return parseInt(ret * 100 ) /100;
}
function doCalc(){
	var str = '';
	var K =parseFloat( $('#ipt_K').val() ) || 0.7;
	for (var i = 1; i <= 50; i++) {
		str += i + ' : ' + calc(i,K) + '   <span style="color:green;">ARPR</span> : '+ sumCalc(i,K) +  '<br>';
	};
	$('#calcResult').html(str);
}
$(doCalc);

function sumCalc(n, K){
	//sum(  K^n*(1-K)*n  )
	K = K || 0.7;
	var ret = 0;
	for(var i=1; i <=n; ++i){
		ret += Math.pow(K,i) * (1-K) * i;
	}
	return ret;
}

</script>
</body>
</html>